package com.tbit.uqbike.webmanager.controller;

import com.tbit.uqbike.object.pojo.dto.OrderAnalysisQueryDTO;
import com.tbit.uqbike.object.pojo.vo.OrderAnalysisVO;
import com.tbit.common.entity.view.PageResult;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.service.business.OrderAnalysisService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 订单流失分析
 *
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @version 1.0
 * @since 2024-7-11
 */
@RestController
@RequestMapping("/orderAnalysis")
public class OrderAnalysisController {

    @Resource
    private OrderAnalysisService orderAnalysisService;

    /**
     * 分页查询订单流失分析
     *
     * @param orderAnalysisQueryDTO 查询条件
     * @return 分页查询结果
     */
    @PostMapping("/queryOrderAnalysis")
    public Result<PageResult<OrderAnalysisVO>> queryOrderAnalysis(@RequestBody OrderAnalysisQueryDTO orderAnalysisQueryDTO) {
        PageResult<OrderAnalysisVO> pageResult = orderAnalysisService.queryOrderAnalysis(orderAnalysisQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 导出订单流失分析
     *
     * @param orderAnalysisQueryDTO 查询条件
     * @return excel
     */
    @PostMapping("/exportOrderAnalysis")
    public Result<Object> exportOrderAnalysis(@RequestBody OrderAnalysisQueryDTO orderAnalysisQueryDTO) {
        return orderAnalysisService.exportOrderAnalysis(orderAnalysisQueryDTO);
    }

    /**
     * 订单流失分析计算漏斗
     * @param orderAnalysisQueryDTO 查询条件
     * @return result
     */
    @PostMapping("/orderAnalysisFunnel")
    public Result<Object> orderAnalysisFunnel(@RequestBody OrderAnalysisQueryDTO orderAnalysisQueryDTO) {
        return orderAnalysisService.orderAnalysisFunnel(orderAnalysisQueryDTO);
    }

    /**
     * 订单流失分析折线图
     * @param orderAnalysisQueryDTO 查询条件
     * @return result
     */
    @PostMapping("/orderAnalysisLine")
    public Result<Object> orderAnalysisLine(@RequestBody OrderAnalysisQueryDTO orderAnalysisQueryDTO){
        return orderAnalysisService.orderAnalysisLine(orderAnalysisQueryDTO);
    }


}
